package com.tobeface.wechat.request.api;

import com.tobeface.modules.lang.Requires;
import com.tobeface.modules.lang.Strings;
import com.tobeface.wechat.request.AbstractWeChatApiRequestBuilder;
import com.tobeface.wechat.request.WeChatRequest;

/**
 * @author loudyn
 */
public class GetAllUsersApiRequestBuilder extends AbstractWeChatApiRequestBuilder {

    private String nextOpenId;

    /**
     *
     */
    public GetAllUsersApiRequestBuilder() {
        super("https://api.weixin.qq.com/cgi-bin/user/get", WeChatRequest.Verb.GET);
    }

    /**
     * @param nextOpenId
     * @return
     */
    public GetAllUsersApiRequestBuilder afterOpenId(String nextOpenId) {
        Requires.hasText(nextOpenId);
        this.nextOpenId = nextOpenId;
        return this;
    }

    @Override
    protected void configRequest(WeChatRequest request) {
        if (Strings.isBlank(nextOpenId)) {
            return;
        }
        request.addQueryParam("next_openid", nextOpenId);
    }
}
